<?php
// +----------------------------------------------------------------------
// | 特性管理
// +----------------------------------------------------------------------
namespace app\passport\controller;
use app\passport\model\User as UserModel;

class User extends Base {

    private $UserModel;

    public function _initialize() {
        parent::_initialize();
        $this->UserModel = new UserModel;
    }

    /**
     * 列表
     * @access public
     */
    public function index(){
        $this->isAuth('passport.user.index');
        //菜单开始
        $pathMaps = [
            ['name'=>'<i class="iconfont icon-home"></i> '.lang('lang_user_ui_title'),'url'=>'javascript:;']
        ];
        $editMenu = [
            ['name'=>'<i class="iconfont icon-cjsqm"></i> '.lang('lang_ui_add'),'url'=>url('passport/user/add')]
        ];
        $this->assign('pathMaps',json_encode($pathMaps));
        $this->assign('editMenu',json_encode($editMenu));
        //菜单结束
        $info = $this->UserModel->select_lists();
        $counts = $this->UserModel->select_lists_counts();
        $page = $info->render();
        $this->assign('lists',$info);
        $this->assign('counts',$counts);
        $this->assign('page',$page);
        return $this->fetch(); 
    }
    
    /**
     * 锁定
     * @access public
     */
    public function lock() {
        $this->isAuth('passport.user.edit');
        $id    = input('id/d');
        $locks = input('locks/d');
        $data  = ['id'=>$id,'locks'=>$locks];
        $result  = $this->UserModel->update_data($data);
        if(!$result){
            return json(['code'=>1,'message'=>lang('lang_message_error')]);
        }else{
            return json(['code'=>0,'message'=>lang('lang_message_success')]);
        }
    } 
}